home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / DEM / I-M / LineShare DEMO.sea / LineShare Scripts / EXAR Fax&TeleFinder < prev    next >
Text File  |  1992-12-25  |  5KB  |  243 lines

  1. !
  2. ! LineShare™ Script for 2400/9600 data-fax modems (EXAR-based)
  3. !
  4. ! This script is designed to use with the TeleFinder™ BBS.
  5. !
  6. ! For some reasons TeleFinder redefines the LineFeed character (S4)
  7. ! We don't redefine it really, but we emulate modem responses with that symbol
  8. ! This trick is done with the lines marked with '$$$$'
  9. !
  10. ! If you want to modify this script for your modem, pay attention to
  11. ! the line marked "#### Settings ####" - it should be modified first
  12. !
  13. ! The TeleFinder "Host Options" used:
  14. ! "Adjust BPS to line speed" - *disabled*
  15. ! "Use Break Reset" - *enabled*,
  16. !
  17.  
  18. ! ------------------------------------------
  19. ! Resetting the modem:
  20. ! ------------------------------------------
  21. @Hangup
  22.   SetTries 2
  23.   Flush
  24.   HsReset 0,0,17,19,0,0
  25. !
  26. ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
  27. ! to enter the command mode
  28. !
  29. @Label 1
  30.   matchclr
  31.   matchstr 1 2 "OK\r\n"
  32.   write "ATH0&F\r"
  33.   matchread 20
  34.   Write "+++"
  35.   DtrClear
  36.   pause 10
  37.   DtrSet
  38. !
  39.   DecTries
  40.   IfTries 0 1
  41. !
  42. ! OSErr -6019 "Modem error - the modem is not responding"
  43. !
  44.   exit -6019
  45. @Label 2
  46.   write "AT+FCLASS=0\r"
  47.   Jsr 100
  48.   write "AT+FAA=0\r"
  49.   Jsr 100
  50.   exit 0
  51. ! ------------------------------------------
  52. !    Receiving incoming calls
  53. ! ------------------------------------------
  54. @ANSWER
  55. @Label 10
  56. !
  57. ! Set the modem preferred speed first
  58. !
  59.   SERRESET 2400,0,8,1
  60.   Jsr 80
  61. !
  62. ! Set the common options
  63.   Jsr 70
  64. !
  65. ! Set the communication options:
  66. ! Extended response set
  67. ! Enable MNP for TeleFinder
  68. ! Xon/Xoff flow control (for Fax)
  69. ! Fax mode (to enable fax tuning commands)
  70. !
  71. @Label 11
  72. ! #### Settings ####
  73.   Write "ATX4\\N3\\Q1&S1+FCLASS=2\r"
  74.   Jsr 100
  75. !
  76. ! Set the "work" speed
  77. !
  78. @Label 12
  79.   SERRESET 19200,0,8,1
  80.   Jsr 80
  81. !
  82. ! Set Fax parameters: LID, DCC,BOR
  83. !
  84.   Write "AT+FLID=\"Stalker_GmbH\"\r"
  85.   Jsr 100
  86.   Write "AT+FDCC=1,3,0,2,0,0,0,0\r"
  87.   Jsr 100
  88.   Write "AT+FBOR=1\r"
  89.   Jsr 100
  90. !
  91. ! Allow modem to receive fax messages
  92. !
  93.   Write "AT+FCR=1\r"
  94.   Jsr 100
  95. !
  96. ! Tell the modem to determine the type of the incoming call
  97. ! Fetch the tube after N rings, where N has been set in the control panel (^4)
  98. !
  99.   Write "ATS0=^4+FAA=1\r"
  100.   Jsr 100
  101. !
  102. ! Everything is ready - let's sit and wait for a call
  103. ! We'll wait for 2 minutes, then reinitiate the modem
  104. @Label 20
  105.   MatchClr
  106.   matchstr 1 20 "RING\r"
  107.   matchstr 2 21 "CONNECT"
  108.   matchstr 13 30 "+FCON"
  109.   matchstr 14 10 "\r\nNO  "
  110.   matchstr 15 10 "BUSY"
  111.   Matchread 1200
  112.   jump 10
  113. !
  114. ! Data connection has been established (we read "CONNECT")
  115. ! Remove everything till "\r\n" from the buffer
  116. ! Emulate the CONNECT 2400 message
  117. ! Attach the "TF" subPort
  118. !
  119. @Label 21
  120.   MatchClr
  121.   MatchStr 1 22 "\r\n"
  122.   MatchRead 10
  123.   exit -6019
  124. @Label 22
  125.   QueueInput "\r\27CONNECT 2400\r\27"
  126.   Attach "TF" (DTR,BREAK,ESCAPE,IDLELIMIT=60)
  127. !
  128. ! Fax connection has been established (we read "+FCON")
  129. ! Put the +FCON back to the buffer,
  130. ! Put the "RING" before the "+FCON"
  131. ! Attach the "Fax" subPort
  132. !
  133. @Label 30
  134.   QueueInput "\r\nRING\r\n\r\n+FCON"
  135.   Attach "Fax" (DTR,RESET,ESCAPE,IDLELimit=30)
  136. ! ------------------------------------------
  137. ! Originating a call through the "Fax" subPort
  138. ! ------------------------------------------
  139. @ORIGINATE "Fax"
  140. !
  141. ! Set the preffered speed
  142. !
  143. ! SERRESET 2400,0,8,1
  144. ! Jsr 80
  145. !
  146. ! Set the common options
  147. !
  148. ! Jsr 70
  149. !
  150. ! Set the "Data" speed
  151. !
  152.   SERRESET 19200,0,8,1
  153.   Jsr 80
  154. !
  155. ! Set the Fax mode
  156. !
  157.    Write "AT+FCLASS=2\r"
  158.   Jsr 100
  159. !
  160. ! Now emit all commands that the application has sent to that port,
  161. ! Prepare to receive all error result codes
  162. !
  163. !EmitClear "S","S","S","&","&","\\","\\"
  164.   Jsr 60
  165. !
  166. ! Prepare to connect
  167. !
  168.   Jsr 90
  169.   MatchStr 1 51 "\r\n+FCON"
  170.   HsReset *
  171.   Write "ATD^1\r"
  172.   MatchRead 700
  173.   Write "\r"
  174.   Exit -6019
  175. @LABEL 51
  176.   QueueInput "\r\n+FCON"
  177.   Attach "Fax" (DTR,RESET,ESCAPE,IDLELimit=30)
  178. !
  179. ! This section emits all modem commands sent by the client application
  180. ! For each set of commands the "OK" answer is awaited
  181. !
  182. @Label 60
  183.   EmitStart
  184. @Label 61
  185.   EmitCommand 62
  186.   Jsr 100
  187.   Jump 61
  188. @Label 62
  189.   return
  190. !
  191. ! This section initiates the modem before ANSWER and ORIGINATEs:
  192. ! factory settings + speaker control +
  193. ! reset on Dtr drop + DCD valid
  194. ! Verbal responses mode, no echo 
  195. ! Set &S1 (DSR) in case the cable connects the DSR signal with the CTS pin
  196. !
  197. @Label 70
  198.   Write "ATM^2L^3&D2&C1V1E0\r"
  199.   Jsr 100
  200.   return 
  201. !
  202. ! This section syncronize the modem after the serial port speed switching
  203. !
  204. @Label 80
  205.   ChrDelay 1
  206.   Write "AT\r"
  207.   ChrDelay 0
  208.   Jsr 100
  209.   return
  210. !
  211. ! Prepare to receive error result codes
  212. !
  213. @Label 90
  214.   MatchClr
  215.   MatchStr 2 91 "NO DIALTONE\r\n"
  216.   MatchStr 3 92 "BUSY\r\n"
  217.   MatchStr 4 93 "NO CARRIER\r\n"
  218.   MatchStr 5 94 "NO ANSWER\r\n"
  219.   return
  220. @Label 91
  221.   exit -6020
  222. @Label 92
  223.   exit -6022
  224. @Label 93
  225.   exit -6021
  226. @Label 94
  227.   exit -6023
  228. !
  229. ! Processing the AT command:
  230. ! OK -> proceed
  231. ! ERROR or TimeOut ->exit -6019
  232. ! It can be called AFTER the "Write" command, since LineShare buffers input
  233. !
  234. @Label 100
  235.   MatchClr
  236.   MatchStr 1 102 "\r\nOK\r\n"
  237.   MatchStr 2 101 "\r\nERROR\r\n"
  238.   MatchRead 20
  239. @Label 101
  240.   Exit -6019
  241. @Label 102
  242.   return
  243.